﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Globalization;

namespace testy {
	/// <summary>
	/// klasa odpowiedzi do pytania
	/// </summary>
	public class Answer {
		protected double pt;
		protected bool isProper;
		protected string content;
		public Answer () {
			this.pt = 0;
			this.isProper = false;
			this.content = "";
		}
		public Answer (string content, double pt = 0, bool isProper = false) {
			this.content = content;
			this.pt = pt;
			this.isProper = isProper;
		}
		public Answer (XmlNode a) : this() { 
			XmlElement an = (XmlElement) a;
			double.TryParse(an.GetAttribute("pt"), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat , out this.pt);
			bool.TryParse(an.GetAttribute("isProper"), out this.isProper);
			this.content = an.InnerText;
		}
		public string generateXML () {
			string output = "";
			output += "<answer pt=\"" + this.pt + "\" isProper=\"" + this.isProper + "\">" + this.content + "</answer>";
			return output;
		}
		public double Pt {
			get { return this.pt; }
			set { this.pt = value; }
		}
		public bool IsProper {
			get { return this.isProper; }
			set { this.isProper = value; }
		}
		public string Content {
			get { return this.content; }
			set { this.content = value; }
		}
	}
}
